/**
 * 定义应用路由
 */
import React from 'react';
import { Router, hashHistory, } from 'react-router';
import auth from './auth';
import Login from "./pages/Login";
import HeaderAsideFooterResponsiveLayout from './layouts/HeaderAsideFooterResponsiveLayout';
import BlankLayout from './layouts/BlankLayout';
import Home from './pages/Home';
import { NotFound, BasicException, NotPermission, EmptyContent } from './pages/ErrorPage';
import { User, AddUser } from "./pages/User";
import Index from './pages/Index/Index'
import IndexAdd from './pages/Index/Add'
import IndexEdit from './pages/Index/Edit'
import PayInfo from './pages/Pay/Info'
import PayDetail from './pages/Pay/Detail'
import SettingAbout from './pages/Setting/About'
import SettingHelp from './pages/Setting/Help'
import SettingLicense from './pages/Setting/License'

const autoGeneratedRoutes = [{
  path: "/login",
  component: BlankLayout,
  indexRoute: { component: Login },
  onEnter: auth
},{
  path: "/loginout",
  component: BlankLayout,
  indexRoute: { component: Login },
  onEnter: auth
},{
  path: "/index",
  component: HeaderAsideFooterResponsiveLayout,
  indexRoute: { component: Index },
  childRoutes: [{
    path: "add",
    component: IndexAdd,
    onEnter: auth
  }, {
    path: "edit/:id",
    component: IndexEdit,
    onEnter: auth
  }],
  onEnter: auth
},{
  path: "/pay",
  component: HeaderAsideFooterResponsiveLayout,
  childRoutes: [{
    path: "info",
    component: PayInfo,
    onEnter: auth
  }, {
    path: "detail",
    component: PayDetail,
    onEnter: auth
  }],
  onEnter: auth
},{
  path: "/setting",
  component: HeaderAsideFooterResponsiveLayout,
  childRoutes: [{
    path: "about",
    component: SettingAbout,
    onEnter: auth
  }, {
    path: "help",
    component: SettingHelp,
    onEnter: auth
  }, {
    path: "license",
    component: SettingLicense,
    onEnter: auth
  }],
  onEnter: auth
},{
  path: "/user",
  childRoutes: [{
    path: "list",
    component: User,
    onEnter: auth
  }, {
    path: "add",
    component: AddUser,
    onEnter: auth
  }],
  component: HeaderAsideFooterResponsiveLayout,
  onEnter: auth
}, {
  path: "/error",
  childRoutes: [{
    path: "401",
    component: NotPermission
  }, {
    path: "404",
    component: NotFound
  }, {
    path: "500",
    component: BasicException
  }, {
    path: "empty",
    component: EmptyContent
  }],
  component: HeaderAsideFooterResponsiveLayout,
  indexRoute: {
    component: NotFound
  }
}, {
  path: '/',
  childRoutes: [{
    path: '*',
    childRoutes: [],
    component: NotFound
  }],
  component: HeaderAsideFooterResponsiveLayout,
  indexRoute: {
    component: Index
  },
  onEnter: auth
}];
// <!-- auto generated routes end -->

// 自定义路由，如果 path 相同则会覆盖自动生成部分的路由配置
const customRoutes = [];

export default (
  <Router history={hashHistory} routes={[...autoGeneratedRoutes, ...customRoutes]} />
);
